<template>
	<om-formsub-outer :index="index" :checkedit="checkedit">
		<om-autoform ref="autoform" :initConfigData="autoformdata" :initValue="initValue"></om-autoform>
	</om-formsub-outer>
</template>

<script>
	import {buildSubFormData, subOnLoad,getEditorTitle, changeEditor,configSelectData,hasValue} from '@/static/js/formUtil.js';
	import { ignoreHtml,ptFloat,minusF,getDateStr} from '@/static/js/common.js';
	export default {
		provide() {
			return {
				formPage: this
			};
		},
		data() {
			return buildSubFormData({
				exists:"",
				itemCache:"hr-u-tempInstAdjust-item-cache",
				userc1Cache:"hr-u-tempInstAdjust-user1-cache",
				userc2Cache:"hr-u-tempInstAdjust-user2-cache"
			})
		},
		methods:{
			
		},
		onShow() {
			let _that = this
			if(_that.$refs.autoform){
				uni.getStorage({
					key:_that.userc1Cache,
					success:(res)=>{
						if(res.data){
							let data = res.data
							let formdata = _that.$refs.autoform.formdata
							formdata.transferOffId = 
							uni.removeStorage({
								key:_that.userc1Cache
							})
						}
					}
				})
				uni.getStorage({
					key:_that.userc2Cache,
					success:(res)=>{
						if(res.data){
							let data = res.data
							let formdata = _that.$refs.autoform.formdata
							
							uni.removeStorage({
								key:_that.userc2Cache
							})
						}
					}
				})
				uni.getStorage({
					key:_that.itemCache,
					success:(res)=>{
						if(res.data){
							let data = res.data
							let formdata = _that.$refs.autoform.formdata
							Object.assign(formdata,data)
							uni.removeStorage({
								key:_that.itemCache
							})
						}
					}
				})
			}
		},
		onLoad(e) {
			let _that = this
			subOnLoad(_that, e, function() {
				_that.exists = _that.datas.filter((e,i)=>{
					return (i != _that.index)
				}).map(e=>e.instId).join(",")
			if(e.configDataCacheKey){
				uni.getStorage({
					key: e.configDataCacheKey,
					success: function(res) {
						if(res.data && Object.prototype.toString.call(res.data)==='[object Array]'){
							_that.autoformdata = res.data
							Object.assign(_that.initValue, _that.formdata)
							_that.autoformdata[0].order = _that.order
								let title = getEditorTitle("title_handle","itemId",_that.autoformdata)
								changeEditor("title_handle","itemId",{
									link:"../../public/search/search",
									"linkParam":{
										other:JSON.stringify({
											itemIds:_that.exists,
											x:3
										}),
										url:"hrCommon/getItemCombobox",
										cachename:_that.itemCache,
										initload:true,
										namefield:'itemName',
										notefield:'remark',
										placeholder:'请输入'+title
									}
								},null,_that.autoformdata)
								changeEditor("title_handle","transferOffId",{
									link:'../../public/pageSearch/pageSearch',
									"linkParam":{
										other:JSON.stringify(),
										url:"tempPosAdjust/getComboboxAll",
										cachename:_that.userc1Cache,
										initload:true,
										searchfield:"q",
										namefield:'userSalaryPosInstName',
										extrafield:"salaryPosInstName",
										placeholder:"请输入姓名"
									}
								},null,_that.autoformdata)
								changeEditor("title_handle","receiveOffId",{
									link:'../../public/pageSearch/pageSearch',
									"linkParam":{
										other:JSON.stringify(),
										url:"tempPosAdjust/getComboboxAll",
										cachename:_that.userc2Cache,
										initload:true,
										searchfield:"q",
										namefield:'userSalaryPosInstName',
										extrafield:"salaryPosInstName",
										placeholder:"请输入姓名"
									}
								},null,_that.autoformdata)
							}
						}
					})
				}
			})
		}
	}
</script>

<style>
</style>                                                                                                                                                                                                                                                                                                                                                                                                                                                         
